package com.example.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.model.CommonResult;
import com.example.entity.domain.Classify;
import com.example.entity.dto.BaseDTO;
import com.example.entity.vo.ClassifyVo;
import com.example.service.ClassifyService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: tjatse
 * @Date: 2025/05/07/21:39
 * @Description:
 */

@Tag(name = "分类管理")
@RestController
@RequestMapping("/classify")
public class ClassifyController {

    @Resource
    private ClassifyService classifyService;

    @RequestMapping("/list")
    public CommonResult<Page<ClassifyVo>> list(@RequestBody BaseDTO baseDTO) {
        return CommonResult.success(classifyService.list(baseDTO));
    }

    @RequestMapping("/add")
    public CommonResult<Boolean> add(@RequestBody Classify classify) {
        return CommonResult.success(classifyService.add(classify));
    }

    @RequestMapping("/delete")
    public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
        return CommonResult.success(classifyService.delete(id));
    }

    @RequestMapping("/update")
    public CommonResult<Boolean> update(@RequestBody Classify classify) {
        return CommonResult.success(classifyService.update(classify));
    }
}
